function [ep]=calculateEngineCost(engine)
% Function that estimates turboprop engine + propellers price
%
% INPUT:
%   engine [struct]
%
% OUTPUT:
%   ep [int]
%
% LIMITATIONS/RESTRICTIONS:
%   Engine`s shp must be grater than 400
%
% AUTHOR: Pietro A R Cerchiari
% REVISION:1.0

%% Load data
    shp=engine.shpTakeOff; %shaft horse power during take off
    nbPropellers=engine.nbPropellers; %number of propellers
    propeller_type=lower(engine.propMaterial); %propeller type: M for metal or C for composite
    
%% Calculate turboprop engine price
if (shp<400)
    error('Engine price can`t be determined. SHP must be grater than 400.')
elseif (shp>5000)
    SF=shp/20.424;
    if SF>1
        ep=2.836*2160000*(0.4*SF+0.6);
    else
        ep=2.836*2160000*(0.533*SF+0.467);
    end
else
    ep=2.05*10^(2.5262+0.9465*log10(shp));
end

%% Calculate proppelers price and add it to engine`s price
if propeller_type=='m'                              %metal propellers
    ep=ep+nbPropellers*(2.05*10^(0.6119+1.1432*log10(shp)));
else                                                %composite propellers
    ep=ep+nbPropellers*(2.05*10^(0.7746+1.1432*log10(shp)));
end